package bintree.heap.leetcode;

/**
 * 比较两个单词顺序
 * @author haomin
 * @date 2022/03/23 22:50
 **/
public class ComperTwoWord {
    public static void main(String[] args) {
        String a = "aab";
        String b = "aa";
        System.out.println(compareVersion(a,b));
    }
    public static int compareVersion(String version1, String version2) {
        char[] data1 = version1.toCharArray();
        char[] data2 = version2.toCharArray();

        for (int n = 0; n < Math.max(version1.length(),version2.length()); n++) {
            int i = (n < data1.length ? (int)data1[n] : 0);
            int j = (n < data2.length ? (int)data2[n] : 0);

            if(i < j){
                return -1;
            }else if(i > j){
                return 1;
            }
        }
        return 0;
    }
}